<?php

namespace App\Http\Requests\Api;

use Illuminate\Foundation\Http\FormRequest;

class PayTypeRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules = [
            'pay_type' => 'required|between:1,3',
        ];
        if($this->pay_type == 1 || $this->pay_type == 3){
            $rules['security'] = 'required';
        }

        return $rules;
    }

    public function messages()
    {
        $messages = [
            'pay_type.required' => '付款方式必须',
            'pay_type.between' => '付款方式错误',
        ];
        
        if($this->pay_type == 1 || $this->pay_type == 3){
            $messages['security.required'] = '支付密码必须';
        }

        return $messages;

    }


}
